package cn.tedu._06article.base.ceptors;

import cn.tedu._06article.base.response.JsonResult;
import cn.tedu._06article.pojo.vo.UserVO;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import org.springframework.web.servlet.HandlerInterceptor;

public class LoginCeptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        HttpSession session=request.getSession();
        UserVO userVO =(UserVO) session.getAttribute("user");
        if(userVO==null)
        {
            response.sendRedirect("login.html");
            return false;
        }
        return true;
    }
}






